{% extends "admin/base_site.html" %}
{% load i18n admin_urls static admin_modify %}
{% block extrahead %}{{ block.super }}
    <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
    {{ media }}
{% endblock %}
{% block extrastyle %}{{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}"/>{% endblock %}
{% block content %}
    <style type="text/css">
        .inline-group .tabular td.original p {
            margin-top: -33px;
        }
        .page-header {
            padding: 10px;
        }
    </style>
    <div id="content-main" class="form-main">

        <div class="page-header">
            <div class="el-page-header">

                <div class="el-page-header__content">任务执行</div>
            </div>
        </div>

        <style type="text/css">
            .inline-group .tabular td.original p {
                margin-top: -50px;
                height: 1.2em;
            }

            .page-header {
                padding: 10px;
            }
        </style>
        <div id="content-main" class="form-main">

                {% csrf_token %}
<form  name='form' id='form' action="" method="post">
    {% csrf_token %}



                <div>

                    <fieldset class="module aligned ">

                        <div class="form-row field-name">

                            <div>

                                <label class="required" for="select_task">任务选择:</label>

                                <select name="select_task" id="select_task">
                                    {% for k, v in project.items %}

                                        <option value="{{ k }}" selected="">{{ k }}</option>

                                    {% endfor %}
                                </select>

                            </div>

                        </div>

                        <div class="form-row field-name">

                            <div>

                                <label class="required" for="select_action">动作:</label>

                                <select name="select_action" id="select_action"></select>

                            </div>

                        </div>

                        <div class="form-row field-status">

                            <div>

                                <label class="required" for="id_status">任务描述:</label>

                                <textarea name="config" cols="5" rows="5" class="vLargeTextField" required="" id="id_config">111</textarea>

                            </div>

                        </fieldset>

                        <style type="text/css">
                            #imgs img {
                                width: 24%;
                            }
                        </style>

                        <div class="submit-row">

                            <button type="submit" name="_save" class="el-button el-button--primary el-button--small">
        提交
        </button>
                            <input type="hidden" name="actionName" value="actionValue" id="actionName"></div>

                    </div>

                </form>
                <script>
                    var project = {{project | safe }};
                    var selectId = document.getElementById("select_task"); //获取ID
                    var actionId = document.getElementById("select_action"); //获取ID
                    _name = selectId
                        .options[selectId.selectedIndex]
                        .innerHTML; //获取选中文本
                    for (index in project[_name]) {
                        actionId
                            .options
                            .add(new Option(project[_name][index]["name"], project[_name][index]["name"]))
                    }

                    selectId.onchange = function () {
                        actionId.options.length = 0;

                        _name = selectId
                            .options[selectId.selectedIndex]
                            .innerHTML; //获取选中文本
                        for (index in project[_name]) {
                            actionId
                                .options
                                .add(new Option(project[_name][index]["name"], project[_name][index]["name"]))
                        }

                    }
                </script>
            </div>

        {% endblock %}